/**
 * 重置支付密码 执行
 * @param newPayPsw    用户输入的新支付密码
 */
function ajaxResetPayPsw(newPayPsw) {
    loading("数据提交中...");
    var url = "/Lvscore_User_M/account/ajaxResetPayPsw";
    $.ajax({
        url: url,
        data: {'newPayPsw': newPayPsw},
        //timeout:10000,
        type: "post",
        success: function (data) {
            $(".loadingBox").hide();
            if (data == 1) {
                window.location.href = "/Lvscore_User_M/userWeb/views/accounterCenter/setPaymentPsdSucc.html";
            } else {
                validateSpanMsg("newPsd1", '支付密码不能和登录密码相同');
            }
        },
        error: function () {
            alertBox("网络异常，请重试", "");
        },
        dataType: "json"
    });
}
$(function () {
    $(".newPassword").val("");
    $(".sure").val("");
    //实时监控输入框
    inputChange(".newPassword", "#newPsd1");
    inputChange(".sure", "#newPsd2");
    inputChange(".newPassword", "#defrentError");
    inputChange(".sure", "#defrentError");
    function newPsdMessage1() {
        var newPsd = $(".newPassword").val();
        if (newPsd == null || newPsd == "") {
            validateSpanMsg("newPsd1", "请输入新密码");
            return false;
        } else if (!(isPassword(newPsd))) {
            validateSpanMsg("newPsd1", "密码格式不正确");
            return false;
        } else {
            return true;
        }
    }

    function newPsdMessage2() {
        var confPsd = $(".sure").val();
        var newPsd = $(".newPassword").val();
        if (confPsd == null || confPsd == "") {
            validateSpanMsg("newPsd2", "请确认新密码");
            return false;
        } else if (newPsd != confPsd) {
            validateSpanMsg("defrentError", "两次输入的密码不一致");
            return false;
        } else {
            return true;
        }
    }

    $(".newPassword").blur(function () {
        newPsdMessage1();
    })
    $(".sure").blur(function () {
        newPsdMessage2();
    })
    getUrl('accounterCenter/accounterSecurity', "accounterCenter/changePaymentPassword", 'ADadmin/payment/contenter', 'ADadmin/payment/friend', 'ADadmin/accounterMoney/bankTransfer', 'ADadmin/payment/friendLink', 'ADadmin/payment/buyAPP');
    $(".sub").click(function () {
        var psd = $(".newPassword").val();
        if (newPsdMessage1() && newPsdMessage2()) {
            ajaxResetPayPsw(psd);
        }
    });
});
